<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('广场动态列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>创建人：</p>
                                <input type="text" name="userPhone"/>
                            </li>
<!--                            <li>-->
<!--                                <p>动态限制 (1公开的，2仅自己看)：</p>-->
<!--                                <input type="text" name="trendLimit"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <p>动态内容：</p>-->
<!--                                <input type="text" name="trendsContenttai"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <p>动态相册：</p>-->
<!--                                <input type="text" name="gallery"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <p>删除标志 1有效-1删除：</p>-->
<!--                                <input type="text" name="dataFlag"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <p>动态类型 1,原创,2,转发：</p>-->
<!--                                <select name="trendsType" th:with="type=${@dict.getType('trends_type')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <p>转发原动态Id：</p>-->
<!--                                <input type="text" name="relayId"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zangchat:chatTrends:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zangchat:chatTrends:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zangchat:chatTrends:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zangchat:chatTrends:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zangchat:chatTrends:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zangchat:chatTrends:remove')}]];
        var selectcommentFlag = [[${@permission.hasPermi('zangchat:comments:list')}]];
        var trendLimitDatas = [[${@dict.getType('trend_limit')}]];
        var trendsTypeDatas = [[${@dict.getType('trends_type')}]];
        var prefix = ctx + "zangchat/chatTrends";


        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "广场动态",
                columns: [{
                    checkbox: true
                },
                // {
                //     field : 'trendsId',
                //     title : '动态id',
                //     visible: false
                // },
                {
                    field : 'userPhone',
                    title : '创建人'
                },
                {
                    field : 'trendLimit', 
                    title : '动态限制',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(trendLimitDatas, value);
                    }
                },
                {
                    field : 'trendsContenttai',
                    title : '动态内容'
                },
                // {
                //     field : 'gallery',
                //     title : '动态相册'
                // },
                // {
                //     field : 'dataFlag',
                //     title : '删除标志 1有效-1删除'
                // },
                {
                    field : 'trendsType', 
                    title : '动态类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(trendsTypeDatas, value);
                    }
                },
                {
                    field : 'relayId', 
                    title : '转发原动态Id'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + selectcommentFlag + '" href="javascript:void(0)" onclick="selectcomment(\'' + row.trendsId + '\')"><i class="fa fa-edit"></i>查看评论</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.trendsId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.trendsId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function selectcomment(trendsId) {

            var index = layer.open({
                type: 2,
                title: '动态评论',
                area: ['80%', '80%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content:  ctx + "zangchat/comments",
                success: function(layero, index){
                    var body=layer.getChildFrame('body',index);//少了这个是不能从父页面向子页面传值的
                    //获取子页面的元素，进行数据渲染
                    body.contents().find("#trendsId").val(trendsId);
                    body.contents().find("#tr-search").click();
                },
            });
            // $.ajax({
            //     url:  ctx + "zangchat/comments",
            //     type: "post",
            //     datatype: "json",
            //     data: {
            //         trendsId: trendsId,
            //     },
            //     success: function (data) {
            //         window.location.reload();
            //     }
            // })

        }

    </script>
</body>
</html>